﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
    <#include "../common/link.ftl" >
    <script>
        $(function () {
            /*删除点击事件*/
            $(".btn-delete").click(function () {
                //获取当前点击的字典目录id
                var id = $(this).data('id');
                $.messager.confirm("警告", "是否确认删除?", function () {
                    $.get(
                        '/systemDictionary/delete.do',
                        {"id": id}, handlerMessage)
                })
            });

            /*模态框*/
            $(".btn-input").click(function () {
                // 清空表单中所有input中的value值
                $("#editForm input").val('');
                // 获取事件源,通过data获取data开头属性的数据
                var json = $(this).data('json');
                console.log(json);
                if (json) {
                    $('#editForm input[name=id]').val(json.id);
                    $('#editForm input[name=title]').val(json.title);
                    $('#editForm input[name=sn]').val(json.sn);
                    $('#editForm input[name=intro]').val(json.intro);
                }
                /*打开模块框*/
                $("#inputModal").modal('show');
            })
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemDictionary"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典目录管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemDictionary/list.do"
                      method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input"
                       style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>字典目录名称</th>
                            <th>字典目录编号</th>
                            <th>字典目录简介</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as systemDictionary>
                            <tr style="font-weight: bolder;color:green">
                                <td>${systemDictionary_index+1}</td>
                                <td>${(systemDictionary.title)!}</td>
                                <td>${(systemDictionary.sn)!}</td>
                                <td>${(systemDictionary.intro)!}</td>
                                <td>
                                    <a href="#" data-json='${(systemDictionary.json)!}'
                                       class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a href="#" data-id="${(systemDictionary.id)!}"
                                       class="btn btn-danger btn-xs btn-delete">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl" >
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<#--模态框,动态弹出所以要给按钮添加点击事件-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel" style="font-weight: bolder" align="center">字典目录添加/修改</h4>
            </div>
            <#--添加表单-->
            <form class="form-horizontal" action="/systemDictionary/saveOrUpdate.do" method="post" id="editForm">
                <div class="modal-body">
                    <input type="hidden" value="${(systemDictionary.id)!}" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-4 control-label">名称：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control col-sm-6" id="title" name="title"
                                   value="${(systemDictionary
                                   .title)!}"
                                   placeholder="请输入字典目录名">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-4 control-label">编码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control col-sm-6" id="sn" name="sn"
                                   value="${(systemDictionary.sn)!}"
                                   placeholder="请输入字典目录编码">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-4 control-label">简介：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control col-sm-6" id="intro" name="intro"
                                   value="${(systemDictionary.intro)!}"
                                   placeholder="请输入字典目录简介">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" style="background-color:
                red"><font color="black" style="font-weight: bolder">关闭</font>
                    </button>
                    <button id="submitBtn" type="submit" class="btn btn-primary"><font color="black"
                                                                                       style="font-weight: bolder">保存</font>
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>